
let baseUrl = 'http://10.220.10.165:3000'
let showLoadind = () => {
  wx.showLoading({
    title: '正在拼命加载...',
    mask: true
  })
}
let hideLoading = () => {
  wx.hideLoading()
}
// 发起请求
let request = (params, callback) => {
  let target = {}
  let defaultParams = {
    isLoading: true // 是否显示loading
  }
  Object.assign(target,defaultParams, params)
  if (target.isLoading) {
    showLoadind()
  }
  wx.request({
    url: params.url,
    success: res => {
      callback && callback(res)
      if (target.isLoading) {
        hideLoading()
      }
    }
  })
}
// 获取榜单列表
export let getMusicList = (id, callback) => {
  request({url:`${baseUrl}/top/list?idx=${id}`}, callback)
}

// 获取歌曲详情
export let getSongById = (id, callback) =>{
  request({ url: `${baseUrl}/song/detail?ids=${id}`}, callback)
}

// 获取歌词
export let getLyricById = (id, callback) => {
  request({
    url:`${baseUrl}/lyric?id=${id}`,
    isLoading:false
  }, callback)
}